<#import "/admin/_layout.html" as layout>
<@layout.header "用户"></@layout.header>
<@layout.body>
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-left">
                        <li class="breadcrumb-item"><a href="#">用户</a></li>
                        <li class="breadcrumb-item active">编辑</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>

    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <div class="card card-primary card-outline card-outline-tabs">
                        <div class="card-header p-0 pt-1">
                            <ul class="nav nav-tabs" role="tablist">
                                <li class="nav-item">
                                    <a class="nav-link active">基本信息</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="/admin/user/pwd?id=${(user.id)!}">修改密码</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="/admin/user/role?id=${(user.id)!}">角色分配</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="/admin/user/tag?id=${(user.id)!}">标签设置</a>
                                </li>
                            </ul>
                        </div>
                        <div class="card-body">
                            <div class="tab-content" id="custom-tabs-one-tabContent">
                                <div class="tab-pane fade show active">
                                    <form id="myForm" method="POST" action="/admin/user/doEdit" ok="/admin/user/list">
                                        <input type="hidden" name="id" value="${(user.id)!}">
                                            <div class="form-group">
                                                <label for="userName">登录账号</label>
                                                <input type="text" name="loginAccount" class="form-control" id="loginAccount" placeholder="登录账号不可以修改" readonly value="${(user.loginAccount)!}">
                                            </div>

                                            <div class="form-group">
                                                <label for="nickName">昵称</label>
                                                <input type="text" name="nickName" class="form-control" id="nickName" placeholder="请输入昵称" value="${(user.nickName)!}">
                                            </div>

                                            <div class="form-group">
                                                <label for="userName">真实姓名</label>
                                                <input type="text" name="userName" class="form-control" id="userName" placeholder="请输入真实姓名" value="${(user.userName)!}">
                                            </div>

                                            <div class="box box-solid" style="width: 200px;">
                                                <div class="box-header with-border ">
                                                    <label for="thumbnail">缩略图</label>
                                                </div>
                                                <div class="box-body no-padding">
                                                    <img src="${(user.headImg)!'/static/img/default.jpg'}"
                                                         style="width: 100%;height: 200px"
                                                         id="thumbnail">
                                                    <input type="hidden" value="${(user.headImg)!}" name="headImg" id="articleThumbnail">
                                                </div>
                                                <div class="box-footer">
                                                    <button type="button" class="btn-image-browser btn btn-default btn-sm "
                                                            for-src="thumbnail"
                                                            for-input="articleThumbnail">选择图片
                                                    </button>
                                                    <a href="javascript:;" style="padding-left: 15px" id="removeThumbnail">移除</a>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <#assign _status=(user.status)!1 />
                                                <label for="status_sel">状态</label>
                                                <select class="form-control" id="status" name="status">
                                                    <option value="1" <@selectedIf value=(_status ==1)/>>启用</option>
                                                    <option value="0" <@selectedIf value=(_status ==0)/>>停用</option>
                                                </select>
                                            </div>
                                            <button type="submit" class="btn btn-primary">提交</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <!-- /.card -->
                    </div>
                </div>
            </div>
        </div>
    </section>
</@layout.body>
<@layout.script>
    <script>
        $("#removeThumbnail").on("click", function () {
            $("#thumbnail").attr("src", "/static/img/default.jpg");
            $("#articleThumbnail").val("");
        })
        $(function () {
            submitForm({
                userName: { required: true},
                nickName: { required: true},
                password: { required: true, minlength: 6 },
                confirm_password: { required: true, minlength: 5 },
            }, {
                password: {required: "请输入密码", minlength: "密码不能少于6位" },
                confirm_password: {required: "请再次输入密码", minlength: "密码不能少于6位" },
            })
        });
    </script>
</@layout.script>